import Vue from 'vue'
import Router from 'vue-router'

import dashboardRouter from '@/router/modules/dashboard'
import classroomRouter from "./modules/classroom";
import deviceRouter from "./modules/device";
import deviceGroupRouter from "./modules/deviceGroup";
import logRouter from "./modules/deviceRuntimeLog";
import dictionaryRouter from "./modules/dictionary";
import userRouter from "./modules/user";

Vue.use(Router);

// 解决点击路由跳转相同地址报错问题
const originalPush = Router.prototype.push;
Router.prototype.push = function push(location) {
    return originalPush.call(this, location).catch(err => err)
};

export const constantRouterMap = [
    // {
    //   path: '/login',
    //   name: 'login',
    //   component: () => import('@/views/login/index'),
    //   hidden: true
    // },
    dashboardRouter,
    classroomRouter,
    deviceRouter,
    deviceGroupRouter,
    logRouter,
    dictionaryRouter,
    userRouter,
    {
        path: '/',
        redirect: '/dashboard/index',
        hidden: true
    }
];

export default new Router({
    mode: 'history',
    base: '/admin/',
    scrollBehavior: () => ({y: 0}),
    routes: constantRouterMap
})
